﻿CREATE TRIGGER [dbo].[tr_Verification_Sync#INSERT]
ON [dbo].[t_Verification]
FOR INSERT--,UPDATE
AS

IF @@ROWCOUNT = 0 RETURN

IF NOT UPDATE(MenuID) RETURN

INSERT INTO t_Loan_Verification(VerificationID, LoanID,Checked)
SELECT i.ID, VS.LoanID, i.DefaultValue
FROM t_VerificationSmart VS
INNER JOIN  t_Verification V ON V.MenuID = VS.StatusID
INNER JOIN inserted ON V.ID = inserted.ID
CROSS JOIN inserted i

--EXEC sp__Context_ArchiveOff 0


--DECLARE @T TABLE(
--ID	int,ParentID	int,Lable	sysname,Description	sysname,DescToBroker	sysname,Pos	int,PageID	int,ImageTypeID	int,
--DefaultValue	bit,MenuID	int,IsSmart	bit,IsParent	bit)
--BEGIN TRAN
--INSERT INTO t_Verification(Lable,Pos,MenuID)
--OUTPUT inserted.* INTO @T
--VALUES('Test 8',3,70)
--SELECT * FROM t_Verification ORDER BY ID DESC
----DELETE t_Verification WHERE MenuID = 56 IN(160,167,169)
--SELECT * FROM t_VerificationSmart WHERE StatusID = 70
--SELECT * FROM @T T INNER JOIN t_Loan_Verification L_V ON L_V.VerificationID = T.ID
--ROLLBACK
